float error[14];
float value[14];

void setup() {
  Serial.begin(9600);
  for (int i = 0; i < 14; ++i)
  {
    value[i] = 0.f;
    error[i] = 0.f;
    pinMode(i, OUTPUT);  
  }
}

void loop()
{
    if (Serial.available() > 1) {
      int index = Serial.read();
      int incomingByte = Serial.read();
      if (index > -1 && index < 14)
      {
        value[index] = log(incomingByte/255.0f);
      }
    }
    for (int i = 0; i < 14; ++i)
    {
      int ledState;
      if (0.5f > value[i] + error[i]) 
      {
        ledState = HIGH;
        error[i] += 1.f - value[i];
      } else {
        ledState = LOW;
        error[i] -= value[i];
      }
    // set the LED with the ledState of the variable:
    digitalWrite(i, ledState);
    }
   // delay(1);
}

